package com.example.demo.pdfbox.common;

import lombok.Data;

@Data
public class PdfMargin {
    private static final float POINTS_PER_INCH = 72;

    /**
     *
     */
    private static final float POINTS_PER_MM = 1 / (10 * 2.54f) * POINTS_PER_INCH;

    private float marginHead;
    private float marginFoot;
    private float marginLeft;
    private float marginRight;

    public static final PdfMargin NORMAL = new PdfMargin(2.54f,2.54f,3.18f,3.18f);
    public static final PdfMargin NARROW = new PdfMargin(1.27f,1.27f,1.27f,1.27f);
    public static final PdfMargin MODERATE = new PdfMargin(2.54f,2.54f,1.27f,1.27f);
    public static final PdfMargin BROAD = new PdfMargin(2.54f,2.54f,5.08f,5.08f);


    public PdfMargin(float marginHead, float marginFoot, float marginLeft, float marginRight, float unit) {

        this.marginHead = marginHead * unit;
        this.marginFoot = marginFoot * unit;
        this.marginLeft = marginLeft * unit;
        this.marginRight = marginRight * unit;
    }

    public PdfMargin(float marginHead, float marginFoot, float marginLeft, float marginRight) {
        this.marginHead = marginHead * POINTS_PER_MM;
        this.marginFoot = marginFoot * POINTS_PER_MM;
        this.marginLeft = marginLeft * POINTS_PER_MM;
        this.marginRight = marginRight * POINTS_PER_MM;
    }
}
